from collections import defaultdict

import matplotlib.pyplot as plt
import numpy as np

plt.rcParams['font.family'] = 'SimHei'
plt.rcParams['font.size'] = 12

dic = defaultdict(int)
with open('./10302.txt', 'r', encoding='utf-8') as fr:
    for length in fr.readlines():
        length = int(length)
        if length < 2560:
            dic[length] += 1

x = np.arange(2560)
y = np.array([dic[i] for i in x])

plt.title('报文长度分布图', size=24)
plt.xlabel('长度')
plt.ylabel('数量')
plt.plot(x, y)

plt.show()
